package com.tjsinfo.tjsoa.articles.bo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IHibernateDao;
import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.articles.vo.TIndexArticles;
import com.tjsinfo.tjsoa.articles.vo.TIndexView;
import com.tjsinfo.tjsoa.common.PaginationSupport;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.THyjyManage;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.TXingzhengfawenNeirong;

public class THyjyManageBO implements ITHyjyManageBO {
	private IQbcDao qbcDao;
	private IHibernateDao hibernateDao;
	public IQbcDao getQbcDao() {
		return qbcDao;
	}
	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	} 
	public IHibernateDao getHibernateDao() {
		return hibernateDao;
	}
	public void setHibernateDao(IHibernateDao hibernateDao) {
		this.hibernateDao = hibernateDao;
	}

	public void saveHyjy(THyjyManage hyjyManage) {
		// TODO Auto-generated method stub
		hibernateDao.saveObject(hyjyManage);
	}
	public void delteHyjy(String hyjyid) {
		// TODO Auto-generated method stub
		Integer hyjy_id= Integer.parseInt(hyjyid);
		THyjyManage hyjy = (THyjyManage) hibernateDao.findById(THyjyManage.class, hyjy_id);
		hibernateDao.delete(hyjy);
	}
	public PaginationSupport findqikandangnian(String sstart, String slimit) {
		// TODO Auto-generated method stub
	//	Date dateToday = new Date(); 
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengfawenNeirong.class);
		criteria.add(Restrictions.eq("state", 2));
	//	criteria.add(Restrictions.isNotNull("fawendatetime"));		
	//	criteria.add(Restrictions.ge("fawendatetime", 2));
		List<Order> orderlist = new ArrayList<Order>();
		orderlist.add(Order.desc("fawendatetime"));
		PaginationSupport ps= qbcDao.findPageByCriteria(criteria,orderlist,Integer.parseInt(slimit), Integer.parseInt(sstart));
		return ps;
	}
	
	public TXingzhengfawenNeirong finddocbyid(String id) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengfawenNeirong.class);
		criteria.add(Restrictions.eq("id", id));
		return  (TXingzhengfawenNeirong) qbcDao.getCriteria(criteria).iterator().next();
	}

	public PaginationSupport findhyjybytype(Integer type,String sstart, String slimit) {
		// TODO Auto-generated method stub
	//	Date dateToday = new Date(); 
		DetachedCriteria criteria = DetachedCriteria.forClass(THyjyManage.class);
		criteria.add(Restrictions.eq("type", type));
	//	criteria.add(Restrictions.isNotNull("fawendatetime"));		
	//	criteria.add(Restrictions.ge("fawendatetime", 2));
		List<Order> orderlist = new ArrayList<Order>();
		orderlist.add(Order.desc("id"));
		PaginationSupport ps= qbcDao.findPageByCriteria(criteria,orderlist,Integer.parseInt(slimit), Integer.parseInt(sstart));
		return ps;
	}
	
}
